package luj.tool.jnproxyan.framework.lujnet.connect;

import luj.net.api.client.NetConnection;
import luj.net.api.connection.NetDisconnectListener;
import luj.tool.jnproxyan.framework.lujnet.ConnState;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
final class OnC2pDisconnect implements NetDisconnectListener {

  @Override
  public void onDisconnect(Context ctx) {
    ConnState connState = ctx.getConnectionState();
    LOG.debug("浏览器断开2222：{}", connState.getReqId());

    NetConnection p2sConn = connState.getP2sConnection();
    if (p2sConn == null) {
      return;
    }
    p2sConn.close();
  }

  private static final Logger LOG = LoggerFactory.getLogger(OnC2pDisconnect.class);
}
